package com.pig4cloud.pig.test;

import cn.hutool.core.thread.ThreadUtil;
import com.pig4cloud.pig.eager.EagerThreadPoolExecutor;
import com.pig4cloud.pig.eager.TaskQueue;
import org.junit.jupiter.api.Test;

import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @Description : TODO
 * @author: lingnan
 * @date: 2023/6/26
 * @version: 1.0
 */
public class DoSome {

	@Test
	public void test_thread_pool() {
		EagerThreadPoolExecutor executor = new EagerThreadPoolExecutor(1, 2, 20, TimeUnit.SECONDS,
				new TaskQueue<>(1), ThreadUtil.createThreadFactoryBuilder().setNamePrefix("quickly-").build()
				, new ThreadPoolExecutor.AbortPolicy());

		for (int i = 0; i < 5; i++) {
			executor.submit(() ->{
				ThreadUtil.sleep(10);
				System.out.println(Thread.currentThread().getName() + " done...");
			});
		}


	}
}
